package com.wanbangee.marksystem.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wanbangee.marksystem.service.TopScoreCompositionService;

@RestController
public class TopScoreCompositionController {
	
	@Autowired
	private TopScoreCompositionService topScoreCompositionService;
	/**
	 * 查询高分作文，学生信息，题目图片
	 * @param examId
	 * @param examSubId
	 * @return
	 */
	@GetMapping("/topScoreComposition/selectTopScoreComposition")
	public Map<String, Object> selectTopScoreComposition(@RequestParam(value="examId") Integer examId,@RequestParam(value="examSubId") Integer examSubId){
		//用来存储提示信息，和状态码，数据
		Map<String, Object> responseMap = new HashMap<String, Object>();
		
		//调用examListService中的selectExamByGraId方法根据学校id和年级ID查询班级信息
		List<Map> TopScores = topScoreCompositionService.selectSscoreByExamIdAmdExamSubId(examId, examSubId);
		
		if(TopScores == null || TopScores.size() == 0) {
			//查询返回的班级考试为null或者没有，返回状态码10013，此班级没有考试
			responseMap.put("code", 10013);
			responseMap.put("msg", "此科目考试没有高分作文");
		}else {
			//查询得到了年级信息，将数据添加到map中，返回给客户端
			responseMap.put("TopScores", TopScores);
			//返回状态码1001，提示信息：接口成功
			responseMap.put("code", 1001);
			responseMap.put("msg", "接口成功");
		}
		return responseMap;
	}
}
